package com.byt.consultation.utils;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.byt.base.utils.ToastUitl;
import com.byt.common.Constants;

public class MainUtil {

    public static void jumpActivity(Context context, Class<?> cls) {
        jumpActivity(context, cls, null);
    }

    public static boolean jumpActivity(Context context, Class<?> cls, Bundle bundle) {
        if (Constants.getPersonalInfo() != null) {
            switch (Constants.getPersonalInfo().getStatus()) {
                case 3:
                    openActivity(context, cls, bundle);
                    return true;
                case 1:
                    ToastUitl.showShort("当前账户未认证");
                    return false;
                case 2:
                    ToastUitl.showShort("当前账户认证中");
                    return false;
                case 4:
                    ToastUitl.showShort("当前账户认证未通过");
                    return false;
                case 5:
                    ToastUitl.showShort("该账户已冻结，请联系客服");
                    return false;
                default:
                    ToastUitl.showShort("当前账户未认证");
                    return false;
            }
        } else {
            return false;
        }
    }

    public static void jumpActivityFrozen(Context context, Class<?> cls, Bundle bundle) {
        if (Constants.getPersonalInfo() != null) {
            switch (Constants.getPersonalInfo().getStatus()) {
                case 5:
                    ToastUitl.showShort("该账户已冻结，请联系客服");
                    break;
                default:
                    openActivity(context, cls, bundle);
                    break;
            }
        }
    }

    public static void openActivity(Context context, Class<?> cls, Bundle bundle) {
        Intent intent = new Intent();
        intent.setClass(context, cls);
        if (bundle != null) {
            intent.putExtras(bundle);
        }
        context.startActivity(intent);
    }

    public static boolean isShowState() {
        if (Constants.getPersonalInfo() != null) {
            switch (Constants.getPersonalInfo().getStatus()) {
                case 3:
                    return true;
                default:
                    return false;
            }
        } else {
            return false;
        }
    }

  /*  public static void handlerMessagesData(Context mContext, String pushData) {
        if (TextUtils.isEmpty(pushData)) {
            return;
        }
        int template_id = 0;
        String data = "";
        try {
            JSONObject jsonObject = new JSONObject(pushData);
            template_id = jsonObject.optInt("template_id");
            data = jsonObject.optString("data");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Gson gson = new Gson();
        Intent broadcastIntent;
        Bundle bundle = new Bundle();
        switch (template_id) {
            case 1:
                //系统公告消息
                NoticePush noticeResults = gson.fromJson(data, NoticePush.class);
                bundle.putInt(MessagesDetailsActivity.DETAILS_TYPE, 1);
                bundle.putLong(MessagesDetailsActivity.DETAILS_ID, noticeResults.getNotice_id());
                broadcastIntent = new Intent(mContext, MessagesDetailsActivity.class);
                broadcastIntent.putExtras(bundle);
                break;
            case 2:
                //系统通知消息
                MessagePush messageResults = gson.fromJson(data, MessagePush.class);
                bundle.putInt(MessagesDetailsActivity.DETAILS_TYPE, 2);
                bundle.putLong(MessagesDetailsActivity.DETAILS_ID, messageResults.getMessage_id());
                broadcastIntent = new Intent(mContext, MessagesDetailsActivity.class);
                broadcastIntent.putExtras(bundle);
                break;
            case 3:
                //咨询接收消息
                ConsultaReceivePush results = gson.fromJson(data, ConsultaReceivePush.class);
                bundle.putParcelable(ConsultChatActivity.INP_CONSULTA_BEAN, results.getConsulation());
                bundle.putInt(ConsultChatActivity.INP_FACTORY_CHANNEL, 1);
                broadcastIntent = new Intent(mContext, ConsultChatActivity.class);
                broadcastIntent.putExtras(bundle);
                break;
            case 4:
                //咨询订单消息
                ConsultaBean consultaResults = gson.fromJson(data, ConsultaBean.class);
                bundle.putParcelable(ConsultChatActivity.INP_CONSULTA_BEAN, consultaResults);
                bundle.putInt(ConsultChatActivity.INP_FACTORY_CHANNEL, 1);
                broadcastIntent = new Intent(mContext, ConsultChatActivity.class);
                broadcastIntent.putExtras(bundle);
                break;
            case 6:
                //退款通知消息
                ConsultaBean refundResults = gson.fromJson(data, ConsultaBean.class);
                bundle.putParcelable(ConsultChatActivity.INP_CONSULTA_BEAN, refundResults);
                bundle.putInt(ConsultChatActivity.INP_FACTORY_CHANNEL, 1);
                broadcastIntent = new Intent(mContext, ConsultChatActivity.class);
                broadcastIntent.putExtras(bundle);
                break;
            case 11:
                //评价通知消息
                ConsultaBean evaluateResults = gson.fromJson(data, ConsultaBean.class);
                bundle.putParcelable(ConsultChatActivity.INP_CONSULTA_BEAN, evaluateResults);
                bundle.putInt(ConsultChatActivity.INP_FACTORY_CHANNEL, 1);
                broadcastIntent = new Intent(mContext, ConsultChatActivity.class);
                broadcastIntent.putExtras(bundle);
                break;
            default:
                broadcastIntent = new Intent(mContext, MessagesActivity.class);
                break;
        }
        mContext.startActivity(broadcastIntent);
    }*/
}